package com.example.redis.service;

import com.example.redis.pojo.User;
import com.example.redis.repository.UserRepository;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lenovo
 */
@Service("userService")
public class UserService {
    @Resource
    private UserRepository userRepository;

    @Cacheable(value = "user",keyGenerator = "keyGenerator")
    public User getUser(Long usrId) {
        return userRepository.findById(usrId).get();
    }
}
